
package edu.faytechcc.csc251.mvc.concrete;

import edu.faytechcc.csc251.mvc.AbstractController;
import java.awt.Color;

/**
 * This controller implements the required methods and provides the properties
 * necessary to work with the DisplayViewPanel and PropertyViewPanel views. Each of
 * methods in this class can be called upon by the views to update to state of the
 * registered models.
 *
 * @author Robert Eckstein
 */
public class ColorController extends AbstractController
{

    /**
     * Change the entire Color object in the model
     * @param color The new Color object
     */
    public void changeColor(Color color) {
        setModelProperty(ColorProperties.COLOR, color);                                 
    }
    
    /**
     * Change the Red component of the Color object in the model. Note,
     * the value for red must be [0-255]. 
     * @param red The new Red component of the Color object
     */
    public void changeRedComponent(int red) {
        if(red < 0 || red > 255 ) {
            throw new IllegalArgumentException("Red must be [0 - 255] was:" + red);
        }
        setModelProperty(ColorProperties.RED, red);  
    }
    
    /**
     * Change the Green component of the Color object in the model. Note,
     * the value for green must be [0-255]. 
     * @param green The new Green component of the Color object
     */
    public void changeGreenComponent(int green) {
        if(green < 0 || green > 255 ) {
            throw new IllegalArgumentException("Green must be [0 - 255] was:" + green);
        }
        setModelProperty(ColorProperties.GREEN, green);  
    }   
    
    /**
     * Change the Blue component of the Color object in the model. Note,
     * the value for blue must be [0-255]. 
     * @param blue The new Blue component of the Color object
     */
    public void changeBlueComponent(int blue) {
        if(blue < 0 || blue > 255 ) {
            throw new IllegalArgumentException("Blue must be [0 - 255] was:" + blue);
        }
        setModelProperty(ColorProperties.BLUE, blue);  
    }     

   
}
